﻿#include "Graph.h"
#include "Simple_window.h"
//#include "Window.h"
//#include "GUI.h"
int main()
{
	using namespace Graph_lib;
	Point t1(100,100);
	Simple_window win (t1, 600, 400, "ex_1");
	Graph_lib::Rectangle rect_1(Point(300,200), 200, 100);
	rect_1.set_color(Color::red);
	win.attach(rect_1);
	
	Graph_lib::Polygon poly;
	poly.add(Point(100,100));
	poly.add(Point(300,100));
	poly.add(Point(300,200));
	poly.add(Point(100,200));
	poly.set_color(Color::blue);
	win.attach(poly);

	win.wait_for_button();
	//*************************************************************
	win.detach(poly);
	win.detach(rect_1);
	int rw = 100;
	int rh = 300;
	
	Point ru_corner((win.x_max()-rw)/2, (win.y_max()-rh)/2);
	Graph_lib::Rectangle rect_2(ru_corner, rw, rh);
	
	string word = "Hello, world!";
	Point txt_point((win.x_max()-rw)/2+5,win.y_max()/2); 
	Text t(txt_point, word);
	t.set_font_size(rh/word.size()/1.28);
	win.attach(t);
	win.attach(rect_2);
	
	win.set_label("ex_2");
	win.wait_for_button();
	//*************************************************************
	win.detach(t);
	win.detach(rect_2);
	
	Line_style ls(Line_style::solid, 5);
	Color l1_color = Color::red;
	Color l2_color = Color::yellow;
	Color l3_color = Color::green;
	
	Point l11(20, 380); 
	Point l12(l11.x+65, l11.y);
	Point l13(l11.x+130, l11.y);
	Point l14(l11.x, l11.y-150);
	Point l15(l12.x, l12.y-135);
	Point l16(l13.x, l13.y-150);
	
	Line ln1(l11, l13);
	ln1.set_style(ls);
	ln1.set_color(l1_color);
	Line ln2(l11, l14);
	ln2.set_style(ls);
	ln2.set_color(l1_color);
	Line ln3(l12, l15);
	ln3.set_style(ls);
	ln3.set_color(l1_color);
	Line ln4(l13, l16);
	ln4.set_style(ls);
	ln4.set_color(l1_color);

	win.attach(ln1);
	win.attach(ln2);
	win.attach(ln3);
	win.attach(ln4);

	Point l21(l11.x+140, l11.y);
	Point l22(l21.x+130, l11.y);
	Point l23(l21.x+65,  l21.y-150);
	Point l24(l21.x+32,  l21.y-75);
	Point l25(l22.x-32,  l21.y-75);

	Line ln5(l21, l23);
	ln5.set_style(ls);
	ln5.set_color(l2_color);

	Line ln6(l22, l23);
	ln6.set_style(ls);
	ln6.set_color(l2_color);

	Line ln7(l24, l25);
	ln7.set_style(ls);
	ln7.set_color(l2_color);

	win.attach(ln5);
	win.attach(ln6);
	win.attach(ln7);



	Point l31(l21.x+140, l21.y);
	Point l32(l31.x+130, l21.y);
	Point l33(l31.x+65,  l21.y-150);
	Point l34(l31.x+32,  l21.y-75);
	Point l35(l32.x-32,  l21.y-75);

	Line ln8(l31, l33);
	ln8.set_style(ls);
	ln8.set_color(l3_color);

	Line ln9(l32, l33);
	ln9.set_style(ls);
	ln9.set_color(l3_color);

	Line ln10(l34, l35);
	ln10.set_style(ls);
	ln10.set_color(l3_color);

	win.attach(ln8);
	win.attach(ln9);
	win.attach(ln10);
	
	win.set_label("ex_3");
	win.wait_for_button();
	//*************************************************************
	win.detach(ln1);
	win.detach(ln2);
	win.detach(ln3);
	win.detach(ln4);
	win.detach(ln5);
	win.detach(ln6);
	win.detach(ln7);
	win.detach(ln8);
	win.detach(ln9);
	win.detach(ln10);
	
	
	Graph_lib::Rectangle r1(ru_corner, 50, 50);
	r1.set_fill_color(Color::white);
	Graph_lib::Rectangle r2(Point(ru_corner.x+50, ru_corner.y), 50, 50);
	r2.set_fill_color(Color::red);
	Graph_lib::Rectangle r3(Point(ru_corner.x+100, ru_corner.y), 50, 50);
	r3.set_fill_color(Color::white);
	Graph_lib::Rectangle r4(Point(ru_corner.x, ru_corner.y+50), 50, 50);
	r4.set_fill_color(Color::red);
	Graph_lib::Rectangle r5(Point(ru_corner.x+50, ru_corner.y+50), 50, 50);
	r5.set_fill_color(Color::white);
	Graph_lib::Rectangle r6(Point(ru_corner.x+100, ru_corner.y+50), 50, 50);
	r6.set_fill_color(Color::red);
	Graph_lib::Rectangle r7(Point(ru_corner.x, ru_corner.y+100), 50, 50);
	r7.set_fill_color(Color::white);
	Graph_lib::Rectangle r8(Point(ru_corner.x+50, ru_corner.y+100), 50, 50);
	r8.set_fill_color(Color::red);
	Graph_lib::Rectangle r9(Point(ru_corner.x+100, ru_corner.y+100), 50, 50);
	r9.set_fill_color(Color::white);

	
	win.attach(r1);
	win.attach(r2);
	win.attach(r3);
	win.attach(r4);
	win.attach(r5);
	win.attach(r6);
	win.attach(r7);
	win.attach(r8);
	win.attach(r9);
	
	win.set_label("ex_4");
	win.wait_for_button();

	//*************************************************************
		
	win.detach(r1);
	win.detach(r2);
	win.detach(r3);
	win.detach(r4);
	win.detach(r5);
	win.detach(r6);
	win.detach(r7);
	win.detach(r8);
	win.detach(r9);

	int widht = win.x_max()*2/3;
	int hight = win.y_max()*3/4;
	int line_widht = 50;
	
	Point lu_corn((win.x_max()-widht)/2, (win.y_max()-hight)/2);
	/*Graph_lib::Rectangle rr1(lu_corn, widht, hight);
	win.attach(rr1);*/
	
	
	Point lu_corn1(lu_corn.x-line_widht,lu_corn.y-line_widht);
	Graph_lib::Rectangle rr2(lu_corn1, widht+100, line_widht);
	rr2.set_fill_color(Color::red);
	rr2.set_color(Color::red);
	win.attach(rr2);


	Graph_lib::Rectangle rr3(lu_corn1, line_widht, hight+100);
	rr3.set_fill_color(Color::red);
	rr3.set_color(Color::red);
	win.attach(rr3);

	Point lu_corn2(lu_corn.x-line_widht,lu_corn.y+hight);
	Graph_lib::Rectangle rr4(lu_corn2, widht+100, line_widht);
	rr4.set_fill_color(Color::red);
	rr4.set_color(Color::red);
	win.attach(rr4);
	
	Point lu_corn3(lu_corn.x+widht,lu_corn.y-line_widht);
	Graph_lib::Rectangle rr5(lu_corn3, line_widht, hight+100);
	rr5.set_fill_color(Color::red);
	rr5.set_color(Color::red);
	win.attach(rr5);

	win.set_label("ex_5");
	win.wait_for_button();

//*************************************************************
	win.detach(rr2);
	win.detach(rr3);
	win.detach(rr4);
	win.detach(rr5);
	

	Point h_lu(100, 200);
	Graph_lib::Rectangle house(h_lu, 400, 200);
	win.attach(house);

	
	Point hrp1(Point(h_lu.x-50, h_lu.y));
	Point hrp2(Point(h_lu.x+450, h_lu.y));
	Point hrp3(Point(hrp1.x + (hrp2.x-hrp1.x)/2, h_lu.y - 100));
	
	Graph_lib::Polygon house_roof;
	house_roof.add(hrp1);
	house_roof.add(hrp2);
	house_roof.add(hrp3);
	win.attach(house_roof);
		
	Point w1_lu(h_lu.x+50, h_lu.y+80);
	Graph_lib::Rectangle window1(w1_lu, 80, 80);
	win.attach(window1);
	
	Point w2_lu(w1_lu.x+100, w1_lu.y);
	Graph_lib::Rectangle window2(w2_lu, 80, 80);
	win.attach(window2);
	
	Point wd_lu(w2_lu.x+120, h_lu.y+40);
	Graph_lib::Rectangle door(wd_lu, 80, 160);
	win.attach(door);
		
	win.set_label("ex_7");
	win.wait_for_button();

	//*************************************************************

	win.detach(house);
	win.detach(house_roof);
	win.detach(window1);
	win.detach(window2);
	win.detach(door);

	
	vector <Point> centers; 
	centers.push_back(Point(100,100));
	centers.push_back(Point(200,100));
	centers.push_back(Point(300,100));
	centers.push_back(Point(150,200));
	centers.push_back(Point(250,200));

	int r = 80;
	Line_style ls1(Line_style::solid, 5);
	
	
	Circle c1(centers[0],r);
	Circle c2(centers[1],r);
	Circle c3(centers[2],r);
	Circle c4(centers[3],r);
	Circle c5(centers[4],r);
	
	c1.set_style(ls1);
	c2.set_style(ls1);
	c3.set_style(ls1);
	c4.set_style(ls1);
	c5.set_style(ls1);
	
	c1.set_color(Color::blue);
	c2.set_color(Color::black);
	c3.set_color(Color::red);
	c4.set_color(Color::yellow);
	c5.set_color(Color::green);

	win.attach(c1);
	win.attach(c4);
	win.attach(c2);
	win.attach(c5);
	win.attach(c3);


	win.set_label("ex_8");
	win.wait_for_button();
//*************************************************************
	win.detach(c1);
	win.detach(c4);
	win.detach(c2);
	win.detach(c5);
	win.detach(c3);

	Image ii(Point(50,50), "max.jpg");
	ii.set_mask(Point(50,50), 500, 300);
	Text mn(Point(210,45), "Max");
	mn.set_font_size(20);
	
	win.attach(ii);
	win.attach(mn);
	
	win.set_label("Max");
	win.wait_for_button();
//*************************************************************
}